package io;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

public class FileInputStreamTest {
    public static void main(String[] args) {
        FileInputStream inputStream = null;
        try {
            File file = new File("C:\\Users\\Shinelon\\Desktop\\乱七八糟\\javastudy\\Test.txt");
            inputStream = new FileInputStream(file);

            byte[] b = new byte[3];
            int read = inputStream.read(b);

            while (read != -1){
                String value = new String(b,0,read);
                System.out.print(value);
                read = inputStream.read(b);
            }

//            while (read != -1){
//                System.out.print((char)read);
//                read = inputStream.read();
//            }
        } catch (java.io.IOException e) {
            e.printStackTrace();
        } finally {
            if(inputStream != null){
                try {
                    inputStream.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
